
<?php $action = Yii::app()->controller->action->id; ?>

<ul id="wiz">

	<?php for($i=0;$i<count($menuItems);$i++) :?>
	
		<?php 
		$start_list = false;
		$close_list = false;
		$default_class = 'wiz_arrow';
		$start_class = '';
		$close_class = '';
	
		
		if ($menuItems[0] == $action)
		{
			$selected = true;
			$skip_next = true;
			$right_side_class = $default_class . ' wiz_on_right';
			$left_side_class = $default_class . ' wiz_on_left';
		}
		else
		{
			$selected = false;
			$skip_next = false;
			$right_side_class = $default_class;
			$left_side_class = $default_class;
		}
		
		
		if (0==$i) 
		{
			$start_list = true;
			$start_class .= 'wiz_left';
			$item_class = 'wiz_first';
			
			if ($selected)
			{
				$start_class .= ' wiz_on_left wiz_end_on_left';
			}

		}
		elseif ((count($menuItems)-1)==$i) 
		{
			$close_list = true;
			$close_class = 'wiz_right';
			$item_class = 'wiz_last';
			$skip_next = true;
			
			if ($selected)
			{
				$close_class .= ' wiz_on_right wiz_end_on_right';
			}
		}
		else {
			$item_class = '';
		}
		?>
		
		<?php if ($start_list) :?>
			
			<li class="<?php echo $start_class; ?>"></li>
			<li class="<?php echo $item_class; ?>"><?php echo CHtml::link($menuItems[$i]['name'],array($menuItems[$i]['link'])); ?></li>
			
			<?php if ($selected) : ?>
				<li class="<?php echo $right_side_class; ?>"></li>
			<?php endif; ?>

		<?php elseif ($close_list) : ?>
			
			<?php if (!$skip_next) : ?>
				<li class="<?php echo $left_side_class ; ?>"></li>
			<?php endif; ?>
			<li class="<?php echo $item_class; ?>"><?php echo CHtml::link($menuItems[$i]['name'],array($menuItems[$i]['link'])); ?></li>
			
			<li class="<?php echo $close_class; ?>"></li>
		
		<?php else : ?>
			
			<?php if (!$skip_next) : ?>
				<li class="<?php echo $left_side_class ; ?>"></li>
			<?php endif; ?>
			
			<li class="<?php echo $item_class; ?>"><?php echo CHtml::link($menuItems[$i]['name'],array($menuItems[$i]['link'])); ?></li>
			<li class="<?php echo $right_side_class; ?>"></li>
		
		<?php endif; ?>

	<?php endfor;?>

</ul>
